<template>
    <div>
         <el-input
          size=' small'
          placeholder="公司名称"
          v-model="datas.name"
          clearable>
        </el-input>

        <el-input
          size=' small'
          placeholder="城市"
          v-model="datas.city"
          clearable>
        </el-input>

        <el-input
          size=' small'
          placeholder="街道"
          v-model="datas.street"
          clearable>
        </el-input>


        <el-upload
          class="upload-demo"
          action="https://jsonplaceholder.typicode.com/posts/"
          :on-preview="handlePreview"
          :on-remove="handleRemove"
          :file-list="fileList"
          list-type="picture">
          <el-button size="small" type="primary">点击上传</el-button>
          <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div>
        </el-upload>
        

        <el-row>
          
          <el-button type="primary" @click="put_com">保存</el-button>
        </el-row>

          
    </div>  
</template>

<script>
import { companyapi_GET,Register_PUT, companyapi_PUT } from '../../api/api.js'
export default {
      data(){
        return{
          
          datas:{
            name:'',
            city:'',
            street:'',
            cid:'',
          },


          fileList: [ {name: 'food2.jpeg', url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'}],

          //获取当前用户id
          uid:'',

          //公司信息
          com_list:[],
        }
      },

      created() {
        this.uid = localStorage.getItem('uid')
      },

      mounted() {
        //获取公司信息
        this.get_com()

        
      },

      methods: {

        //修改公司信息
        put_com(){
          // console.log(this.datas)
          companyapi_PUT(this.datas).then(res=>{
            // console.log(res)
            if(res.code==200){
              alert(res.message)
            }
          })
        },


        //文件上传
        handleRemove(file, fileList) {
        console.log(file, fileList);
        },
        handlePreview(file) {
          console.log(file);
        },


        //获取公司信息
        get_com(){
          companyapi_GET({uid:this.uid}).then(res=>{
            console.log(res)

            this.datas.name = res.data.name
            this.datas.city = res.data.city
            this.datas.street = res.data.street
            this.datas.cid = res.data.id
          })
        },


      },
}
</script>

<style>

</style>